home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 85 / CD Temático 40 Febrero 2004.iso / DOS / testdisk / src / ext2.h < prev    next >
Encoding:
C/C++ Source or Header  |  2004-01-02  |  5.6 KB  |  142 lines

  1. /*
  2.  
  3.     File: ext2.h
  4.  
  5.     Copyright (C) 1998-2004 Christophe GRENIER <grenier@cgsecurity.org>
  6.   
  7.     This software is free software; you can redistribute it and/or modify
  8.     it under the terms of the GNU General Public License as published by
  9.     the Free Software Foundation; either version 2 of the License, or
  10.     (at your option) any later version.
  11.   
  12.     This program is distributed in the hope that it will be useful,
  13.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15.     GNU General Public License for more details.
  16.   
  17.     You should have received a copy of the GNU General Public License
  18.     along with this program; if not, write to the Free Software
  19.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20.  
  21.  */
  22. #define EXT2_SB(sb)     (sb)
  23.  
  24. /*
  25.  * The second extended file system magic number
  26.  */
  27. #define EXT2_SUPER_MAGIC    0xEF53
  28. #define EXT2_MIN_BLOCK_SIZE        1024
  29. #define    EXT2_MAX_BLOCK_SIZE        4096
  30. #define EXT2_MIN_BLOCK_LOG_SIZE          10
  31.  
  32. #define EXT2_MIN_BLOCK (EXT2_MIN_BLOCK_SIZE/SECTOR_SIZE)
  33.  
  34. /*
  35.  * File system states
  36.  */
  37. #define    EXT2_VALID_FS            0x0001    /* Unmounted cleanly */
  38. #define    EXT2_ERROR_FS            0x0002    /* Errors detected */
  39.  
  40. /*
  41.  * Behaviour when detecting errors
  42.  */
  43. #define EXT2_ERRORS_CONTINUE        1    /* Continue execution */
  44. #define EXT2_ERRORS_RO            2    /* Remount fs read-only */
  45. #define EXT2_ERRORS_PANIC        3    /* Panic */
  46. #define EXT2_ERRORS_DEFAULT        EXT2_ERRORS_CONTINUE
  47.  
  48. /*
  49.  * Feature set definitions
  50.  */
  51. #define EXT2_HAS_COMPAT_FEATURE(sb,mask)                        \
  52.         ( le32(EXT2_SB(sb)->s_feature_compat) & (mask) )
  53. #define EXT2_HAS_RO_COMPAT_FEATURE(sb,mask)                     \
  54.         ( le32(EXT2_SB(sb)->s_feature_ro_compat) & (mask) )
  55. #define EXT2_HAS_INCOMPAT_FEATURE(sb,mask)                      \
  56.         ( le32(EXT2_SB(sb)->s_feature_incompat) & (mask) )
  57.  
  58. #define EXT2_FEATURE_COMPAT_DIR_PREALLOC        0x0001
  59. #define EXT2_FEATURE_COMPAT_IMAGIC_INODES    0x0002
  60. #define EXT3_FEATURE_COMPAT_HAS_JOURNAL        0x0004
  61. #define EXT2_FEATURE_COMPAT_EXT_ATTR        0x0008
  62. #define EXT2_FEATURE_COMPAT_RESIZE_INO        0x0010
  63. #define EXT2_FEATURE_COMPAT_DIR_INDEX        0x0020
  64. #define EXT2_FEATURE_COMPAT_ANY            0xffffffff
  65.  
  66.  
  67. #define EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER     0x0001
  68. #define EXT2_FEATURE_RO_COMPAT_LARGE_FILE       0x0002
  69. #define EXT2_FEATURE_RO_COMPAT_BTREE_DIR        0x0004
  70. #define EXT2_FEATURE_RO_COMPAT_ANY        0xffffffff
  71.  
  72. #define EXT2_FEATURE_INCOMPAT_COMPRESSION       0x0001
  73. #define EXT2_FEATURE_INCOMPAT_FILETYPE          0x0002
  74. #define EXT3_FEATURE_INCOMPAT_RECOVER        0x0004
  75. #define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV    0x0008
  76. #define EXT2_FEATURE_INCOMPAT_ANY        0xffffffff
  77.                                                     
  78. /*
  79.  * Structure of the super block
  80.  */
  81. struct ext2_super_block {
  82.     __u32    s_inodes_count;        /* Inodes count */
  83.     __u32    s_blocks_count;        /* Blocks count */
  84.     __u32    s_r_blocks_count;    /* Reserved blocks count */
  85.     __u32    s_free_blocks_count;    /* Free blocks count */
  86.     __u32    s_free_inodes_count;    /* Free inodes count */
  87.     __u32    s_first_data_block;    /* First Data Block */
  88.     __u32    s_log_block_size;    /* Block size */
  89.     __s32    s_log_frag_size;    /* Fragment size */
  90.     __u32    s_blocks_per_group;    /* # Blocks per group */
  91.     __u32    s_frags_per_group;    /* # Fragments per group */
  92.     __u32    s_inodes_per_group;    /* # Inodes per group */
  93.     __u32    s_mtime;        /* Mount time */
  94.     __u32    s_wtime;        /* Write time */
  95.     __u16    s_mnt_count;        /* Mount count */
  96.     __s16    s_max_mnt_count;    /* Maximal mount count */
  97.     __u16    s_magic;        /* Magic signature */
  98.     __u16    s_state;        /* File system state */
  99.     __u16    s_errors;        /* Behaviour when detecting errors */
  100.     __u16    s_minor_rev_level;     /* minor revision level */
  101.     __u32    s_lastcheck;        /* time of last check */
  102.     __u32    s_checkinterval;    /* max. time between checks */
  103.     __u32    s_creator_os;        /* OS */
  104.     __u32    s_rev_level;        /* Revision level */
  105.     __u16    s_def_resuid;        /* Default uid for reserved blocks */
  106.     __u16    s_def_resgid;        /* Default gid for reserved blocks */
  107.     /*
  108.      * These fields are for EXT2_DYNAMIC_REV superblocks only.
  109.      *
  110.      * Note: the difference between the compatible feature set and
  111.      * the incompatible feature set is that if there is a bit set
  112.      * in the incompatible feature set that the kernel doesn't
  113.      * know about, it should refuse to mount the filesystem.
  114.      * 
  115.      * e2fsck's requirements are more strict; if it doesn't know
  116.      * about a feature in either the compatible or incompatible
  117.      * feature set, it must abort and not try to meddle with
  118.      * things it doesn't understand...
  119.      */
  120.     __u32    s_first_ino;         /* First non-reserved inode */
  121.     __u16   s_inode_size;         /* size of inode structure */
  122.     __u16    s_block_group_nr;     /* block group # of this superblock */
  123.     __u32    s_feature_compat;     /* compatible feature set */
  124.     __u32    s_feature_incompat;     /* incompatible feature set */
  125.     __u32    s_feature_ro_compat;     /* readonly-compatible feature set */
  126.     __u8    s_uuid[16];        /* 128-bit uuid for volume */
  127.     char    s_volume_name[16];     /* volume name */
  128.     char    s_last_mounted[64];     /* directory where last mounted */
  129.     __u32    s_algorithm_usage_bitmap; /* For compression */
  130.     /*
  131.      * Performance hints.  Directory preallocation should only
  132.      * happen if the EXT2_COMPAT_PREALLOC flag is on.
  133.      */
  134.     __u8    s_prealloc_blocks;    /* Nr of blocks to try to preallocate*/
  135.     __u8    s_prealloc_dir_blocks;    /* Nr to preallocate for dirs */
  136.     __u16    s_padding1;
  137.     __u32    s_reserved[204];    /* Padding to the end of the block */
  138. };
  139. int check_EXT2(t_param_disk *disk_car,t_diskext *partition,const int debug);
  140. int recover_EXT2(t_param_disk *disk_car, const struct ext2_super_block *sb,t_diskext *partition,const int debug, const int dump_ind);
  141. int set_EXT2_info(t_param_disk *disk_car, const struct ext2_super_block *sb,t_diskext *partition,const int debug, const int dump_ind);
  142.